package com.gxa.controller.set;

import com.gxa.common.R;
import com.gxa.entity.TransferManagement;
import com.gxa.service.TransferModeService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("/dataDictionary/transferMode")
@Api(value = "转运方式管理的所有操作测试",tags = "转运方式管理接口API")
public class TransferModeController {

    @Autowired
    private TransferModeService transferModeService;

    /**
     * 添加转运方式
     * @param transferManagement
     * @return
     */
    @RequestMapping(value = "/addTransferMode",method = RequestMethod.POST)
    @ApiOperation(value = "添加转运方式接口",notes = "添加转运方式信息",httpMethod = "POST",response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=1001,message="要添加的信息已存在"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R addTransferMode(@RequestBody @ApiParam(name = "transferManagement",value = "转运方式信息",required = true) TransferManagement transferManagement){
        return transferModeService.addTransferMode(transferManagement);
    }

    /**
     * 修改转运方式
     * @param transferManagement
     * @return
     */
    @RequestMapping(value = "/updateTransferMode",method = RequestMethod.POST)
    @ApiOperation(value = "修改转运方式接口",notes = "修改转运方式信息",httpMethod = "POST",response = R.class)
    @ApiResponses({
            @ApiResponse(code = 200,message = "请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R updateTransferMode(@RequestBody @ApiParam(name = "transferManagement",value = "转运方式信息",required = true) TransferManagement transferManagement){
        return transferModeService.updateTransferMode(transferManagement);
    }

    /**
     * 删除转运方式
     * @param id
     * @return
     */
    @RequestMapping(value = "/deleteTransferMode",method = RequestMethod.POST)
    @ApiOperation(value = "删除转运方式接口",notes = "根据转运方式的编号删除转运方式信息",httpMethod = "POST",response = R.class)
    @ApiImplicitParam(name = "id",value = "要删除的转运方式编号",required = true,dataType = "int",paramType = "query")
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R deleteTransferMode(int id){
        return transferModeService.deleteTransferMode(id);
    }

    /**
     * 分页查询所有转运方式
     * @param currentPage
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "/queryAllTransferModesByPage",method = RequestMethod.GET)
    @ApiOperation(value = "查询所有转运方式接口",notes = "查询所有转运方式进行分页显示",httpMethod = "GET",response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "pageSize",value = "每页显示记录数",required = true,dataType = "int",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R queryAllTransferModesByPage(int currentPage,int pageSize){
        return transferModeService.queryAllTransferModesByPage(currentPage,pageSize);
    }
}
